package com.rcloud.server.sealtalk.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.rcloud.server.sealtalk.constant.ErrorCode;
import com.rcloud.server.sealtalk.controller.param.PacketSendRequest;
import com.rcloud.server.sealtalk.controller.param.ScreenCaptureParam;
import com.rcloud.server.sealtalk.controller.param.SendMessageParam;
import com.rcloud.server.sealtalk.controller.response.FsResponse;
import com.rcloud.server.sealtalk.domain.Groups;
import com.rcloud.server.sealtalk.domain.MessageRongCloudSynchronization;
import com.rcloud.server.sealtalk.domain.ScreenStatuses;
import com.rcloud.server.sealtalk.exception.ServiceException;
import com.rcloud.server.sealtalk.manager.GroupManager;
import com.rcloud.server.sealtalk.manager.MiscManager;
import com.rcloud.server.sealtalk.model.dto.*;
import com.rcloud.server.sealtalk.model.response.APIResult;
import com.rcloud.server.sealtalk.model.response.APIResultWrap;
import com.rcloud.server.sealtalk.rongcloud.RongCloudClient;
import com.rcloud.server.sealtalk.util.*;
import io.micrometer.core.instrument.util.IOUtils;
import io.micrometer.core.instrument.util.StringUtils;
import io.rong.models.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;

/**
 * @Author: xiuwei.nie
 * @Author: Jianlu.Yu
 * @Date: 2020/7/6
 * @Description:
 * @Copyright (c) 2020, rongcloud.cn All Rights Reserved
 */
@Api(tags = "其他相关")
@RestController
@RequestMapping("/misc")
@Slf4j
public class MiscController extends BaseController {

    private Logger logger = LoggerFactory.getLogger(getClass());
    @Value("classpath:squirrel.json")
    private org.springframework.core.io.Resource squirrelResource;

    @Value("classpath:client_version.json")
    private org.springframework.core.io.Resource clientResource;

    @Value("classpath:demo_square.json")
    private org.springframework.core.io.Resource demoSquareResource;

    @Autowired
    private GroupManager groupManager;

    @Autowired
    private MiscManager miscManager;
    @Autowired
    private HttpClient httpClient;
    @Resource
    private RongCloudClient rongCloudClient;

    @Value("${st.api_uri}")
    private String apiUri;

    //融云IM全量消息同步
    @PostMapping("rongCloudMessageSynchronization")
    public APIResult<?> rongCloudMessageSynchronizationXG(@RequestParam String fromUserId, @RequestParam String toUserId, @RequestParam String objectName, @RequestParam String content, @RequestParam String channelType, @RequestParam String msgTimestamp, @RequestParam String msgUID, @RequestParam int sensitiveType, @RequestParam String source, @RequestParam(required = false) String groupUserIds) {
     //   System.out.println("收到消息：" + channelType + " - " + content);
        String filterUser="xwexshk#";
        if(!objectName.equals("RC:TxtMsg")&&!objectName.equals("RC:ImgMsg")){

            return APIResultWrap.ok();
        }

        try {
            MessageRongCloudSynchronization message = new MessageRongCloudSynchronization();
            message.setFrom_user_id(fromUserId == null ? null : N3d.decode(fromUserId));
            message.setTo_user_id(toUserId == null ? null : N3d.decode(toUserId));
            message.setObject_name(objectName);
            JSONObject object = JSONObject.parseObject(content);
            if (object != null && objectName.equals("RC:ImgMsg")) {
                message.setContent(object.getString("imageUri"));
            } else {
                message.setContent(content);
                message.setText(object.getString("content"));
            }
            message.setChannel_type(channelType);
            message.setMsg_timestamp(msgTimestamp == null ? null : Long.valueOf(msgTimestamp));
            message.setMsg_id(msgUID);
            message.setSensitive_type(sensitiveType);
            message.setSource(source);
            message.setGroup_user_ids(groupUserIds);

            System.out.println(message.toString());

            if ("RC:SRSMsg".equals(objectName)) {
                return null;
            }
            //保存消息到本地
            miscManager.saveMessage(message);
        } catch (Exception e) {
            System.out.println("消息同步异常:" + e.getMessage());
            return APIResultWrap.error(-1, e.getMessage());
        }
        return APIResultWrap.ok();
    }

    @ApiOperation(value = "获取客户端最新版本（ Desktop 使用 ）")
    @RequestMapping(value = "/latest_update", method = RequestMethod.GET)
    public void getLatestUpdateVersion(
            @ApiParam(name = "version", value = "版本号", required = true, type = "String", example = "xxx")
            @RequestParam("version") String version,
            HttpServletResponse response) throws ServiceException, IOException {

        try {
            response.setCharacterEncoding("utf8");
            if (StringUtils.isEmpty(version)) {
                response.setStatus(400);
//                response.getWriter().write("Invalid version.");
                response.getWriter().write(JacksonUtil.toJson(APIResultWrap.error(400, "Invalid version.")));

                return;
            }

            String result = CacheUtil.get(CacheUtil.LAST_UPDATE_VERSION_INFO);
            if (StringUtils.isEmpty(result)) {
                String jsonData = IOUtils
                        .toString(squirrelResource.getInputStream(), StandardCharsets.UTF_8);
                result = jsonData;

            }

            String jsonVersion = "";
            JsonNode jsonNode = JacksonUtil.getJsonNode(result);
            if (jsonNode != null) {
                JsonNode v = jsonNode.get("version");
                if (v.isNull()) {
                    response.setStatus(400);
//                    response.getWriter().write("Invalid version.");
                    response.getWriter().write(JacksonUtil.toJson(APIResultWrap.error(400, "Invalid version.")));

                    return;
                } else {
                    jsonVersion = v.asText();
                }
            }

            if (version.compareTo(jsonVersion) > 0) {
                response.setStatus(204);
                return;
            }

            CacheUtil.set(CacheUtil.LAST_UPDATE_VERSION_INFO, result);
            response.getWriter().write(result);
            return;
        } catch (IOException e) {
            response.setStatus(500);
//            response.getWriter().write("server error.");
            response.getWriter().write(JacksonUtil.toJson(APIResultWrap.error(500, "server error.")));

        }
    }


    @ApiOperation(value = "Android、iOS 获取更新版本")
    @RequestMapping(value = "/client_version", method = RequestMethod.GET)
    public void getClientVersion(HttpServletResponse response) throws ServiceException, IOException {
        try {
            response.setCharacterEncoding("utf8");
            String result = CacheUtil.get(CacheUtil.CLIENT_VERSION_INFO);
            if (StringUtils.isEmpty(result)) {
                String jsonData = IOUtils.toString(clientResource.getInputStream(), StandardCharsets.UTF_8);
                result = jsonData;

            }
            CacheUtil.set(CacheUtil.CLIENT_VERSION_INFO, result);
            response.getWriter().write(result);
//            response.getWriter().write(JacksonUtil.toJson(APIResultWrap.error(500, )));
            return;
        } catch (IOException e) {
            response.setStatus(500);
//            response.getWriter().write("server error.");
            response.getWriter().write(JacksonUtil.toJson(APIResultWrap.error(500, "server error.")));
        }
    }

    /**
     * Android、iOS 获取更新版本, 返回 sealtalk 标准数据格式
     *
     * @param response
     * @return
     */
    @ApiOperation(value = "Android、iOS 获取更新版本")
    @RequestMapping(value = "/mobile_version", method = RequestMethod.GET)
    public APIResult<?> getMobileVersion(HttpServletResponse response) {
        try {
            response.setCharacterEncoding("utf8");

            String result = CacheUtil.get(CacheUtil.MOBILE_VERSION_INFO);
            if (StringUtils.isEmpty(result)) {
                String jsonData = IOUtils.toString(clientResource.getInputStream(), StandardCharsets.UTF_8);
                result = jsonData;

            }
            CacheUtil.set(CacheUtil.MOBILE_VERSION_INFO, result);

            return APIResultWrap.ok(JacksonUtil.getJsonNode(result));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return APIResultWrap.error(ErrorCode.SERVER_ERROR);
        }
    }


//    @ApiOperation(value = "Android、iOS 获取更新版本")
//    @RequestMapping(value = "/demo_square", method = RequestMethod.GET)
//    public APIResult<?> getDemoSquare() {
//        try {
//
//            String jsonData = IOUtils.toString(demoSquareResource.getInputStream(), StandardCharsets.UTF_8);
//            ObjectMapper objectMapper = new ObjectMapper();
//            List<DemoSquareDTO> demoSquareDTOList = objectMapper.readValue(jsonData, new TypeReference<List<DemoSquareDTO>>() {
//            });
//
//            List<Integer> groupIds = new ArrayList<>();
//            if (CollectionUtils.isEmpty(demoSquareDTOList)) {
//                return APIResultWrap.ok(null);
//            }
//
//            for (DemoSquareDTO demoSquareDTO : demoSquareDTOList) {
//                groupIds.add(demoSquareDTO.getId());
//            }
//            List<Groups> groupsList = groupManager.getGroupList(groupIds);
//
//            Map<Integer, Groups> groupsMap = new HashMap<>();
//            if (groupsList != null) {
//                for (Groups groups : groupsList) {
//                    groupsMap.put(groups.getId(), groups);
//                }
//            }
//
//            for (DemoSquareDTO demoSquareDTO : demoSquareDTOList) {
//                if ("group".equals(demoSquareDTO.getType())) {
//                    Groups groups = groupsMap.get(demoSquareDTO.getId());
//                    if (groups == null) {
//                        demoSquareDTO.setName("Unknown");
//                        demoSquareDTO.setPortraitUri("");
//                        demoSquareDTO.setMemberCount(0);
//                    } else {
//                        demoSquareDTO.setName(groups.getName());
//                        demoSquareDTO.setPortraitUri(groups.getPortraitUri());
//                        demoSquareDTO.setMemberCount(groups.getMemberCount());
//                        demoSquareDTO.setMaxMemberCount(groups.getMaxMemberCount());
//                    }
//                }
//            }
//            return APIResultWrap.ok(MiscUtils.encodeResults(demoSquareDTOList));
//        } catch (Exception e) {
//            log.error(e.getMessage(), e);
//            return APIResultWrap.error(ErrorCode.SERVER_ERROR);
//        }
//    }

    @ApiOperation(value = "Server API 发送消息")
    @RequestMapping(value = "/send_message", method = RequestMethod.POST)
    public APIResult<Object> sendMessage(@RequestBody SendMessageParam sendMessageParam) throws ServiceException {

        String conversationType = sendMessageParam.getConversationType();
        String targetId = sendMessageParam.getTargetId();
        String objectName = sendMessageParam.getObjectName();
        String content = sendMessageParam.getContent();
        String pushContent = sendMessageParam.getPushContent();

        ValidateUtils.notEmpty(conversationType);
        ValidateUtils.notEmpty(targetId);
        ValidateUtils.notEmpty(objectName);
        ValidateUtils.notEmpty(content);

        Integer currentUserId = getCurrentUserId();
        miscManager.sendMessage(currentUserId, conversationType, N3d.decode(targetId), objectName, content, pushContent, targetId);
        return APIResultWrap.ok();
    }


//    @ApiOperation(value = "Server API 发送消息")
//    @RequestMapping(value = "/send_message_diy", method = RequestMethod.POST)
//    public APIResult<Object> sendDiyMessage(@RequestBody SendMessageParam sendMessageParam) throws ServiceException {
//
//        String conversationType = sendMessageParam.getConversationType();
//        String targetId = sendMessageParam.getTargetId();
//        String objectName = sendMessageParam.getObjectName();
//        Object content = sendMessageParam.getContent2();
//        String pushContent = sendMessageParam.getPushContent();
//
//        ValidateUtils.notEmpty(conversationType);
//        ValidateUtils.notEmpty(targetId);
//        ValidateUtils.notEmpty(objectName);
//        ValidateUtils.notNull(content);
//
//        Integer currentUserId = getCurrentUserId();
//        miscManager.sendDiyMessage(currentUserId, conversationType, N3d.decode(targetId), objectName, content, pushContent, targetId);
//        return APIResultWrap.ok();
//    }

    private PacketXunmi getPacketDetail(Long packetId) throws ServiceException {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("content", "gslgndkowegsd39099j9sjglJDwngslg");
        jsonObject.put("packetId", packetId);

        String xunmi = httpClient.post(apiUri + "api/packet/detail_for_rc", jsonObject);
        FsResponse fsResponse;
        try {
            fsResponse = JSONObject.parseObject(xunmi, FsResponse.class);
        } catch (Exception e) {
            log.error("error of get packet detail:{}", xunmi);
            throw new ServiceException(ErrorCode.XUNMI_SERVER_FAIL);
        }
        if (Objects.isNull(fsResponse) || !fsResponse.isSuccess()) {
            throw new ServiceException(Integer.parseInt(fsResponse.getCode()), fsResponse.getMsg(), HttpStatus.SC_OK);
        }
        JSONObject jsonObject1 = (JSONObject) fsResponse.getData();
        PacketXunmi packet = jsonObject1.toJavaObject(PacketXunmi.class);
//        if (packet.getStatus() != 0) {
//            throw new ServiceException(ErrorCode.XUNMI_SERVER_FAIL);
//        }
        return packet;
    }

    /**
     * 推送红包消息
     */
    @ApiIgnore
    @ApiOperation(value = "推送红包消息")
    @PostMapping("send/group")
    public APIResult<Object> sendPacket(@RequestBody PacketSendRequest params) throws ServiceException {
        params.valid();

        PacketXunmi packet = getPacketDetail(params.getEnvId());

        log.info("packet:{}", JSONObject.toJSONString(packet));
        RCMessageDto messageDto = new RCMessageDto();
        messageDto.setContent(packet.getContent());
        messageDto.setExtra("1");
        if (Objects.nonNull(params.getType()) && params.getType() == 1) {
            messageDto.setUserid(N3d.encode(packet.getReceiveUser()));
            messageDto.setReceiveUserId(N3d.encode(packet.getReceiveUser()));
        }
        messageDto.setRedpacketMoney(packet.getMoney());
        messageDto.setType("ST:RedMsg");
        messageDto.setDestructDuration(0);
        messageDto.setRedPackgeDec(packet.getContent());
        messageDto.setRedPackgeId(packet.getId().intValue());
        Integer currentUserId = getCurrentUserId();
        String chatType= params.getTo();
        if("1".equals(chatType)){
            miscManager.sendPrivateMessage(currentUserId, packet.getGroupId().intValue(), messageDto);

        }else {
            miscManager.sendGroupMsg(currentUserId, packet.getGroupId().intValue(), N3d.encode(currentUserId), new String[]{N3d.encode(packet.getGroupId())}, messageDto);

        }

        return APIResultWrap.ok();
    }

    /**
     * 推送红包消息
     */
    @ApiIgnore
    @ApiOperation(value = "推送红包消息")
    @PostMapping("send/group_notoken")
    public APIResult<Object> sendPacketnotoken(@RequestBody PacketSendRequest params) throws ServiceException {
        params.valid();

        PacketXunmi packet = getPacketDetail(params.getEnvId());

        log.info("packet:{}", JSONObject.toJSONString(packet));
        RCMessageDto messageDto = new RCMessageDto();
        messageDto.setContent(packet.getContent());
        messageDto.setExtra("1");
        if (Objects.nonNull(params.getType()) && params.getType() == 1) {
            messageDto.setUserid(N3d.encode(packet.getReceiveUser()));
            messageDto.setReceiveUserId(N3d.encode(packet.getReceiveUser()));
        }
        messageDto.setRedpacketMoney(packet.getMoney());
        messageDto.setType("ST:RedMsg");
        messageDto.setDestructDuration(0);
        messageDto.setRedPackgeDec(packet.getContent());
        messageDto.setRedPackgeId(packet.getId().intValue());
        //Integer currentUserId = getCurrentUserId();
        miscManager.sendGroupMsg(Integer.parseInt(String.valueOf(packet.getUserId())), packet.getGroupId().intValue(), N3d.encode(packet.getUserId()), new String[]{N3d.encode(packet.getGroupId())}, messageDto);

        return APIResultWrap.ok();
    }


   //领取红包消息-xxx领取了xxx的红包
    @PostMapping("send/group/rptip")
    public APIResult<Object> sendPacketPrtip(@RequestBody RCRptipMessageDto params) throws ServiceException {
        params.valid();
        //Integer currentUserId = getCurrentUserId();
        miscManager.sendGroupMsgTip(params.getReceiveUserId(), params.getTargetId(), params.getReceiveUserId(), new String[]{params.getTargetId()}, params);

        return APIResultWrap.ok();
    }

    //领取红包消息-xxx领取了xxx的红包
    @PostMapping("send/single/rptip")
    public APIResult<Object> sendPacketSinglertip(@RequestBody RCRptipMessageDto params) throws ServiceException {
        params.valid();
        //Integer currentUserId = getCurrentUserId();
        miscManager.sendPrivateMessageTip(params.getReceiveUserId(), params.getTargetId(), params.getReceiveUserId(), new String[]{params.getTargetId()}, params);

        return APIResultWrap.ok();
    }

    /**
     * 支付密码设置
     */
    @RequestMapping("/url")
    public APIResult<Object>  currentUrl(@RequestBody RequestBody params) {

        JSONObject jsonObject =new JSONObject();
        jsonObject.put("url","www.thyx001.com");

        return APIResultWrap.ok(jsonObject);
    }

    /**
     * 推送红包消息
     */
    @ApiIgnore
    @ApiOperation(value = "推送红包消息")
    @PostMapping("send/single")
    public APIResult<Object> sendSinglePacket(@RequestBody PacketSendRequest params) throws ServiceException {
        params.valid();
        PacketXunmi packet = getPacketDetail(params.getEnvId());

        RCTransMessageDto messageDto = new RCTransMessageDto();
        messageDto.setTransAcount(packet.getMoney());
        messageDto.setType("ST:TransMsg");
        messageDto.setTransDes(packet.getContent());
        messageDto.setTransId(packet.getId().intValue());
        miscManager.sendPrivateMessage(getCurrentUserId(), packet.getReceiveUser().intValue(), messageDto);

        return APIResultWrap.ok();
    }

    /**
     * 推送红包消息
     */
    @ApiIgnore
    @ApiOperation(value = "推送红包消息")
    @PostMapping("send/single_notoken")
    public APIResult<Object> sendSinglePacketNotoken(@RequestBody PacketSendRequest params) throws ServiceException {
        params.valid();
        PacketXunmi packet = getPacketDetail(params.getEnvId());

        RCTransMessageDto messageDto = new RCTransMessageDto();
        messageDto.setTransAcount(packet.getMoney());
        messageDto.setType("ST:TransMsg");
        messageDto.setTransDes(packet.getContent());
        messageDto.setTransId(packet.getId().intValue());
        miscManager.sendPrivateMessage(Integer.parseInt(String.valueOf(packet.getUserId())), packet.getReceiveUser().intValue(), messageDto);

        return APIResultWrap.ok();
    }

    @ApiIgnore
    @ApiOperation(value = "提现充值、退回等通知")
    @PostMapping("send/system")
    public APIResult<Object> send(@RequestBody PacketSendRequest params) throws ServiceException {
        if (params.getFrom() == null) throw new AssertionError();
        if (params.getTo() == null) throw new AssertionError();
        if (!"gdjsalgjow390jt3ngflsjg93j4tg3wmn4gw0m342gmsmvdlsmg03".equals(params.getEnvMsg())) {
            return APIResultWrap.error(-1, "错误");
        }
        RCTransMessageDto messageDto = new RCTransMessageDto();
        messageDto.setTransAcount(params.getRedpacketMoney());
        messageDto.setType("ST:ServiceMsg");
        messageDto.setTransDes(params.getContent());
        messageDto.setCtime(params.getCtime());
        messageDto.setBankInfo(params.getBankInfo());
        messageDto.setTransId(params.getEnvId().intValue());
        miscManager.sendServicePrivateMessage(N3d.decode(params.getFrom()), N3d.decode(params.getTo()), messageDto, params.getPushContent());

        return APIResultWrap.ok();
    }


    @ApiIgnore
    @ApiOperation(value = "领取通知-红包已领完")
    @PostMapping("send/redtip")
    public void redtip(@RequestBody PacketSendRequest params) throws ServiceException {
        if (params.getFrom() == null) throw new AssertionError();
        if (params.getTo() == null) throw new AssertionError();
        if (!"gdjsalgjow390jt3ngflsjg93j4tg3wmn4gw0m342gmsmvdlsmg03".equals(params.getEnvMsg())) {
             return;
        }
        log.info("send/redtip=====>接口调用");

//        messageDto.setCtime(params.getCtime());
//        messageDto.setBankInfo(params.getBankInfo());
//        messageDto.setTransId(params.getEnvId().intValue());
        miscManager.sendServiceGroupMessage( params.getFrom(), params.getTo()   ,params.getContent() );


    }

    @ApiIgnore
    @ApiOperation(value = "领取通知-xxx领取了xxx的红包")
    @PostMapping("send/redtip2")
    public void redtip2(@RequestBody PacketSendRequest params) throws ServiceException {
        if (params.getFrom() == null) throw new AssertionError();
        if (params.getTo() == null) throw new AssertionError();
        if (!"gdjsalgjow390jt3ngflsjg93j4tg3wmn4gw0m342gmsmvdlsmg03".equals(params.getEnvMsg())) {
            return;
        }
        log.info("send/redtip=====>接口调用");

//        messageDto.setCtime(params.getCtime());
//        messageDto.setBankInfo(params.getBankInfo());
//        messageDto.setTransId(params.getEnvId().intValue());
      //  miscManager.sendServiceGroupMessage( params.getFrom(), params.getTo()   ,params.getContent(),"RPTipMsg");


    }


    @ApiOperation(value = "截屏通知状态设置")
    @RequestMapping(value = "/set_screen_capture", method = RequestMethod.POST)
    public APIResult<Object> setScreenCapture(@RequestBody ScreenCaptureParam screenCaptureParam) throws ServiceException {

        Integer conversationType = screenCaptureParam.getConversationType();
        String targetId = screenCaptureParam.getTargetId();
        Integer noticeStatus = screenCaptureParam.getNoticeStatus();

        ValidateUtils.notNull(conversationType);
        ValidateUtils.notEmpty(targetId);
        if (noticeStatus == null) {
            throw new ServiceException(ErrorCode.STATUS_NULL);
        }
        ValidateUtils.notNull(noticeStatus);

        Integer currentUserId = getCurrentUserId();

        miscManager.setScreenCapture(currentUserId, N3d.decode(targetId), conversationType, noticeStatus);
        return APIResultWrap.ok();
    }


    @ApiOperation(value = "获取截屏通知状态")
    @RequestMapping(value = "/get_screen_capture", method = RequestMethod.POST)
    public APIResult<Object> getScreenCapture(@RequestBody ScreenCaptureParam screenCaptureParam) throws ServiceException {

        Integer conversationType = screenCaptureParam.getConversationType();
        String targetId = screenCaptureParam.getTargetId();

        ValidateUtils.notNull(conversationType);
        ValidateUtils.notEmpty(targetId);

        Integer currentUserId = getCurrentUserId();

        ScreenStatuses screenStatuses = miscManager.getScreenCapture(currentUserId, N3d.decode(targetId), conversationType);
        Map<String, Object> result = new HashMap<>();
        if (screenStatuses == null) {
            result.put("status", 0);
        } else {
            result.put("status", screenStatuses.getStatus());
        }
        return APIResultWrap.ok(MiscUtils.encodeResults(result));
    }

    @ApiOperation(value = "发送截屏通知消息")
    @RequestMapping(value = "/send_sc_msg", method = RequestMethod.POST)
    public APIResult<Object> sendScreenCaptureMsg(@RequestBody ScreenCaptureParam screenCaptureParam) throws ServiceException {

        Integer conversationType = screenCaptureParam.getConversationType();
        String targetId = screenCaptureParam.getTargetId();

        ValidateUtils.notNull(conversationType);
        ValidateUtils.notEmpty(targetId);

        Integer currentUserId = getCurrentUserId();

        miscManager.sendScreenCaptureMsg(currentUserId, N3d.decode(targetId), conversationType);

        return APIResultWrap.ok();
    }


}
